Skip to content

feat(session-ingest): push notifications for remote session attention signals#4445

Merged
eshurakov merged 9 commits into
mainfrom
likeable-dreadnought
Jul 15, 2026
Merged

feat(session-ingest): push notifications for remote session attention signals#4445
eshurakov merged 9 commits into
mainfrom
likeable-dreadnought

Conversation

@eshurakov

@eshurakov eshurakov commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Session-ingest now sends a mobile push when a remote root session needs attention: the assistant finishes a turn (status -> idle) or the session is waiting for user input (status -> question / permission). This gives VS Code and Agent Manager users a signal to return to a remotely controllable session.

Key behavior:

  • SessionIngestDO.ingest() emits attention signals alongside metadata changes. Completed signals include an excerpt from the latest completed assistant message; needs-input signals use a fixed prompt.
  • queue-consumer collects signals across ingest chunks, persists metadata first, and dispatches pushes best-effort through the notifications service. Signals from already-committed chunks are also dispatched after a later chunk fails, because retries will not re-emit those transitions.
  • Pushes are eligible only for remote-controllable root sessions with a live CLI heartbeat. Recent local CLI activity suppresses the push.
  • The web app registers visibility-gated presence for the canonical Kilo session. The notifications service suppresses pushes when that session is actively open in a visible web tab.
  • Existing Cloud Agent push payloads and completed status are reused for compatibility with deployed notification schemas.

Verification

  • Manually verified with the CLI and local Cloud Agent, including that no push is sent while the session is focused in the web app.
  • pnpm --filter notifications test -- src/lib/notifications-service-cloud-agent.test.ts
  • pnpm --filter notifications typecheck
  • pnpm --filter notifications lint
  • pnpm --filter cloudflare-session-ingest typecheck
  • pnpm --filter cloudflare-session-ingest lint
  • pnpm --filter @kilocode/event-service test -- src/__tests__/presence.test.ts
  • pnpm --filter @kilocode/event-service typecheck
  • pnpm --filter web typecheck
  • git diff --check

Visual Changes

N/A

Reviewer Notes

  • First-status guard: an idle transition only produces a completed signal after the DO has already recorded a status, preventing historic backfills from notifying about old turns.
  • The completed-message lookup is bounded to the 50 newest message rows and skips R2-offloaded rows.
  • Web foreground suppression uses presence rather than websocket subscriptions because subscriptions are not visibility-gated.
  • Push dispatch is non-fatal: failures are logged and never block queue acknowledgement or retry behavior.

@kilo-code-bot

kilo-code-bot Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

The only changes since the last review mark five tests as it.skip in queue-consumer.test.ts and api.test.ts, consistent with the prior commit that disabled remote session attention pushes behind a kill switch; no functional or logic changes were introduced.

Files Reviewed (2 files)
  • services/session-ingest/src/queue-consumer.test.ts
  • services/session-ingest/src/routes/api.test.ts
Previous Review Summaries (9 snapshots, latest commit 667e2af)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 667e2af)

Status: No Issues Found | Recommendation: Merge

Executive Summary

The only change since the last review is a single blank-line removal in a test file; no functional or logic changes were introduced.

Files Reviewed (1 file)
  • services/session-ingest/src/remote-session-notifications.test.ts

Previous review (commit 3f1b5c5)

Status: No Issues Found | Recommendation: Merge

Executive Summary

This commit adds a kill switch (REMOTE_SESSION_ATTENTION_PUSH_ENABLED = false) that unconditionally suppresses remote session attention pushes; no new issues were introduced.

Files Reviewed (2 files)
  • services/session-ingest/src/remote-session-notifications.ts - no issues; dispatchRemoteSessionAttentionSignal now short-circuits to 'suppressed' before any side effects when the feature flag is off
  • services/session-ingest/src/remote-session-notifications.test.ts - no issues; updated test correctly asserts hasActiveCliSession is not even called while the flag is disabled

Note: With pushes globally disabled by this flag, the previously reported findings on services/session-ingest/src/remote-session-notifications.ts:12 (eligibility check missing platform restriction) and services/session-ingest/src/dos/SessionIngestDO.ts:353 (direct-ingest sessions dropping attention signals) are currently unreachable in production, since dispatchRemoteSessionAttentionSignal never proceeds past the kill switch to send a push. Those code paths still contain the underlying defects and should be revisited before the flag is flipped back on.

Previous review (commit 408ce7d)

Status: No Issues Found | Recommendation: Merge

Executive Summary

This commit only removes noisy logging and pushes item-offload filtering into the SQL query itself; no new issues were introduced in the incremental diff.

Files Reviewed (4 files)
  • services/notifications/src/dos/NotificationChannelDO.ts - no issues; resolved prior "Not needed?" comment by inlining dispatchPushCore
  • services/notifications/src/lib/cloud-agent-session-push.ts - no issues; resolved prior "Leftover logs?" comment by removing debug logging
  • services/session-ingest/src/dos/SessionIngestDO.ts - no issues; resolved prior "filter at query level?" comments by adding isNull(item_data_r2_key) to both queries
  • services/session-ingest/src/queue-consumer.ts - no issues; resolved prior "raw console log" comment by removing debug logging

Note: Two previously reported findings remain open on unchanged code and are unaffected by this commit: services/session-ingest/src/remote-session-notifications.ts:12 (eligibility no longer restricts pushes to VS Code/Agent Manager sessions) and services/session-ingest/src/dos/SessionIngestDO.ts:353 (direct-ingest sessions drop attention signals).

Previous review (commit 7a7f89e)

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 1
Issue Details (click to expand)

WARNING

File Line Issue
services/session-ingest/src/remote-session-notifications.ts 12 Eligibility no longer restricts pushes to VS Code or Agent Manager sessions, so local terminal CLI sessions can also receive attention pushes

SUGGESTION

File Line Issue
services/session-ingest/src/queue-consumer.test.ts 1146 The new child-session test lacks a metadata transaction fake and passes through the retry path instead of verifying successful projection and acknowledgement
Files Reviewed (6 files)
  • services/session-ingest/src/ingest/direct-ingest.ts - no issues
  • services/session-ingest/src/queue-consumer.test.ts - 1 issue
  • services/session-ingest/src/queue-consumer.ts - no issues; previous stale platform snapshot finding resolved
  • services/session-ingest/src/remote-session-notifications.test.ts - no issues
  • services/session-ingest/src/remote-session-notifications.ts - 1 existing issue re-verified
  • services/session-ingest/src/routes/api.test.ts - no issues

Fix these issues in Kilo Cloud

Previous review (commit 640c916)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
services/session-ingest/src/queue-consumer.ts 315 Queue dispatch checks the pre-ingest platform snapshot, permanently suppressing a first attention signal when the same payload establishes VS Code or Agent Manager eligibility
Files Reviewed (6 files)
  • services/session-ingest/src/ingest/direct-ingest.ts - no issues; previous direct-ingest finding resolved
  • services/session-ingest/src/queue-consumer.test.ts - no issues
  • services/session-ingest/src/queue-consumer.ts - 1 issue
  • services/session-ingest/src/remote-session-notifications.test.ts - no issues
  • services/session-ingest/src/remote-session-notifications.ts - no issues; previous platform eligibility finding resolved
  • services/session-ingest/src/routes/api.test.ts - no issues

Fix these issues in Kilo Cloud

Previous review (commit 6e10e17)

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
services/session-ingest/src/dos/SessionIngestDO.ts 353 Direct-ingest sessions return attention signals that no caller dispatches, so selected rollout users receive no completed or needs-input pushes
services/session-ingest/src/remote-session-notifications.ts 12 Eligibility still includes local terminal CLI sessions instead of restricting pushes to VS Code/Agent Manager sessions
Files Reviewed (31 files)
  • apps/web/src/components/cloud-agent-next/CloudChatPage.tsx - no issues
  • apps/web/src/hooks/useCliSessionPresence.ts - no issues
  • dev/local/env-sync/parse.ts - no issues
  • dev/local/services.ts - no issues
  • packages/event-service/package.json - no issues
  • packages/event-service/src/__tests__/presence.test.ts - no issues
  • packages/event-service/src/client.ts - no issues
  • packages/event-service/src/presence.ts - no issues
  • packages/notifications/src/rpc-schemas.ts - no issues
  • services/cloud-agent-next/src/session/message-settlement-outbox.test.ts - no issues
  • services/cloud-agent-next/src/session/message-settlement-outbox.ts - no issues
  • services/cloud-agent-next/test/integration/session/push-notifications.test.ts - no issues
  • services/event-service/src/do/user-session-do.ts - no issues
  • services/event-service/src/index.ts - no issues
  • services/event-service/src/util/logger.ts - no issues
  • services/notifications/src/dos/NotificationChannelDO.ts - no issues
  • services/notifications/src/lib/cloud-agent-session-push.ts - no issues
  • services/notifications/src/lib/notifications-service-cloud-agent.test.ts - no issues
  • services/session-ingest/src/dos/SessionIngestDO.ts - 1 issue
  • services/session-ingest/src/dos/UserConnectionDO.test.ts - no issues
  • services/session-ingest/src/dos/UserConnectionDO.ts - no issues
  • services/session-ingest/src/dos/session-ingest-attention.test.ts - no issues
  • services/session-ingest/src/dos/session-ingest-attention.ts - no issues
  • services/session-ingest/src/env.ts - no issues
  • services/session-ingest/src/notifications-binding.ts - no issues
  • services/session-ingest/src/queue-consumer.test.ts - no issues
  • services/session-ingest/src/queue-consumer.ts - no issues
  • services/session-ingest/src/remote-session-notifications.test.ts - no issues
  • services/session-ingest/src/remote-session-notifications.ts - 1 issue
  • services/session-ingest/test/integration/session-ingest-do.test.ts - no issues
  • services/session-ingest/worker-configuration.d.ts - generated; skipped

Fix these issues in Kilo Cloud

Previous review (commit 2362a7a)

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

The latest changes replace web-view push suppression with a presence-based check and add local-CLI-activity suppression, but the previously flagged eligibility gap (local terminal CLI sessions still qualify for pushes, not just VS Code/Agent Manager sessions) remains unresolved since isEligibleForRemoteSessionAttention was not touched in this update.

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
services/session-ingest/src/remote-session-notifications.ts 15 Eligibility check still doesn't restrict pushes to VS Code/Agent Manager sessions; unchanged in this update (previously reported)
Files Reviewed (16 files, incremental)
  • apps/web/src/components/cloud-agent-next/CloudChatPage.tsx - no issues
  • apps/web/src/hooks/useCliSessionPresence.ts - no issues
  • packages/event-service/package.json - no issues
  • packages/event-service/src/__tests__/presence.test.ts - no issues
  • packages/event-service/src/presence.ts - no issues
  • packages/notifications/src/rpc-schemas.ts - no issues
  • services/notifications/src/lib/cloud-agent-session-push.ts - no issues
  • services/notifications/src/lib/notifications-service-cloud-agent.test.ts - no issues
  • services/session-ingest/src/dos/UserConnectionDO.test.ts - no issues
  • services/session-ingest/src/dos/UserConnectionDO.ts - no issues
  • services/session-ingest/src/queue-consumer.test.ts - no issues
  • services/session-ingest/src/queue-consumer.ts - no issues
  • services/session-ingest/src/remote-session-notifications.test.ts - no issues
  • services/session-ingest/src/remote-session-notifications.ts - 1 issue (carried forward, unchanged code)
  • services/session-ingest/src/types/user-connection-protocol.test.ts - no issues
  • services/session-ingest/src/types/user-connection-protocol.ts - no issues

pnpm-lock.yaml was skipped (generated file).

Fix these issues in Kilo Cloud

Previous review (commit e9f3fd2)

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

The incremental changes replace the platform-based push eligibility check with an active-CLI-heartbeat check that no longer restricts remote-session attention pushes to VS Code/Agent Manager sessions, broadening pushes to local terminal CLI sessions as well.

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
services/session-ingest/src/remote-session-notifications.ts 12 Eligibility check dropped the createdOnPlatform restriction; the new hasActiveCliSession gate doesn't restore it, so local terminal CLI sessions now also receive push notifications
Files Reviewed (8 files, incremental)
  • services/notifications/src/index.ts - logging only, no issues
  • services/notifications/src/lib/cloud-agent-session-push.ts - logging only, no issues
  • services/session-ingest/src/dos/UserConnectionDO.test.ts - no issues
  • services/session-ingest/src/dos/UserConnectionDO.ts - no issues
  • services/session-ingest/src/queue-consumer.test.ts - no issues
  • services/session-ingest/src/queue-consumer.ts - no issues
  • services/session-ingest/src/remote-session-notifications.test.ts - no issues
  • services/session-ingest/src/remote-session-notifications.ts - 1 issue

pnpm-lock.yaml was skipped (generated file).

Fix these issues in Kilo Cloud

Previous review (commit 552691c)

Status: No Issues Found | Recommendation: Merge

Executive Summary

Reviewed the new remote-session attention-push pipeline (SessionIngestDO signal detection, queue-consumer dispatch/partial-flush-on-failure, remote-session-notifications eligibility/body-building, and the UserConnectionDO subscriber check) with high confidence and found no security, correctness, or breaking-change issues in the changed code.

Files Reviewed (14 files)
  • services/session-ingest/package.json
  • services/session-ingest/src/dos/SessionIngestDO.ts
  • services/session-ingest/src/dos/UserConnectionDO.test.ts
  • services/session-ingest/src/dos/UserConnectionDO.ts
  • services/session-ingest/src/dos/session-ingest-attention.test.ts
  • services/session-ingest/src/dos/session-ingest-attention.ts
  • services/session-ingest/src/env.ts
  • services/session-ingest/src/notifications-binding.ts
  • services/session-ingest/src/queue-consumer.test.ts
  • services/session-ingest/src/queue-consumer.ts
  • services/session-ingest/src/remote-session-notifications.test.ts
  • services/session-ingest/src/remote-session-notifications.ts
  • services/session-ingest/test/integration/session-ingest-do.test.ts
  • services/session-ingest/wrangler.jsonc

Generated files (pnpm-lock.yaml, worker-configuration.d.ts) were skipped.


Reviewed by claude-sonnet-5 · Input: 20 · Output: 4.5K · Cached: 407.8K

Review guidance: REVIEW.md from base branch main

@eshurakov eshurakov force-pushed the likeable-dreadnought branch from 552691c to e9f3fd2 Compare July 8, 2026 19:28
Comment thread services/session-ingest/src/remote-session-notifications.ts
@eshurakov eshurakov force-pushed the likeable-dreadnought branch 2 times, most recently from 2362a7a to db65f76 Compare July 14, 2026 17:58
… signals

Detect completed assistant turns and needs-input status transitions during
ingest and dispatch a mobile push to the session owner for remote (vscode,
agent-manager) root sessions. Pushes are suppressed when the user already
has the session open in the web app (UserConnectionDO.hasSessionSubscribers).

- SessionIngestDO emits AttentionSignal(s) on idle/question/permission
  transitions, pairing completed turns with the just-finished assistant
  message excerpt. First-ever status writes are skipped to avoid pushing
  about an old turn on full-history backfill.
- queue-consumer collects signals across chunks and dispatches them via a
  NOTIFICATIONS service binding; partial flush on failure preserves
  signals from already-committed chunks.
- Adds @kilocode/notifications dependency and wrangler NOTIFICATIONS binding.
@eshurakov eshurakov force-pushed the likeable-dreadnought branch from db65f76 to ca81a23 Compare July 14, 2026 18:30
Comment thread services/session-ingest/src/dos/SessionIngestDO.ts
Comment thread services/session-ingest/src/queue-consumer.ts Outdated
Comment thread services/session-ingest/src/queue-consumer.test.ts

@iscekic iscekic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly nits, LGTM

Comment thread services/notifications/src/dos/NotificationChannelDO.ts Outdated
Comment thread services/notifications/src/lib/cloud-agent-session-push.ts Outdated
Comment thread services/session-ingest/src/dos/SessionIngestDO.ts Outdated
Comment thread services/session-ingest/src/dos/SessionIngestDO.ts Outdated
Comment thread services/session-ingest/src/queue-consumer.ts Outdated
…lify dispatch paths

- notifications: inline dispatchPushCore into dispatchPush, drop verbose
  console.log outcome logging in cloud-agent-session-push
- session-ingest: push item_data_r2_key filter into SQL queries instead of
  filtering in JS, drop verbose logging in attention signal dispatch
@eshurakov eshurakov merged commit 8d6f385 into main Jul 15, 2026
60 checks passed
@eshurakov eshurakov deleted the likeable-dreadnought branch July 15, 2026 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants